package DesignPattern.CommandPattern;

// 计算器类请求类
//received 真正的命令执行对象
public class Calculator {
    private int result = 0;

    public void add(int operand) {
        result += operand;
        System.out.println("Result: " + result);
    }

    public void subtract(int operand) {
        result -= operand;
        System.out.println("Result: " + result);
    }

    public void multiply(int operand) {
        result *= operand;
        System.out.println("Result: " + result);
    }

    public void divide(int operand) {
        if (operand != 0) {
            result /= operand;
            System.out.println("Result: " + result);
        } else {
            System.out.println("Cannot divide by zero.");
        }
    }
}
